class LimitFilter:
    # 重写filter_queryset方法
    def filter_queryset(self, request, queryset, view):
        # 从get请求中获取了limit的值
        limit_num = request.query_params.get('limit')
        if limit_num:
            limit_num = int(limit_num)
            return queryset[:limit_num]
        return queryset
